{yun:}include file="$comstyle/header.htm"{/yun}
<div class="w1000">
	<div class="admin_mainbody"> 
		{yun:}include file="$comstyle/left.htm"{/yun}
		<div class=right_box>
			<div class=admincont_box>
				<div class="com_tit"><span class="com_tit_span">充值{yun:}$config.integral_pricename{/yun}</span></div>
				
				<div class="com_body">
					<div class="admin_new_tip ">
						<div class="admin_new_tit"><i class="admin_new_tit_icon"></i>温馨提示</div>
						<div class="admin_new_tip_list_cont">
							<div class="admin_new_tip_list"> 
								当前{yun:}$config.integral_pricename{/yun}兑换比为1元={yun:}$config.integral_proportion{/yun}{yun:}$config.integral_priceunit{/yun}{yun:}$config.integral_pricename{/yun}{yun:}if $config.integral_min_recharge>0{/yun}，单次最低充值{yun:}$config.integral_min_recharge{/yun}{yun:}$config.integral_pricename{/yun}。{yun:}/if{/yun}
							</div>
						</div>
					</div>
			  
					<iframe id="fdingdan"  name="fdingdan" onload="returnmessage('fdingdan');" style="display:none"></iframe>
					<form id="alipayment" name="alipayment" target="fdingdan" action="index.php?c=pay&act=dingdan" method="post" onsubmit="return pay_form();">
						<input type="hidden" id="logid" name="logid" />
						<input type="hidden" id="integral" name="price_int" value="{yun:}$integralclass_name[$integralclass_index[0]]{/yun}" />
						<input type="hidden" id="integralid" name="integralid" data-discount="{yun:}$integralclass_discount[$integralclass_index[0]]{/yun}" value="{yun:}$integralclass_index[0]{/yun}" />
						<div class="payment_list">
							<div class="payment_list_s mt10">充值数量：</div>
							<div class="payment_list_r">
								{yun:}foreach from=$integralclass_index item=v key=k{/yun}
									<span class="payment_list_text {yun:}if $k==0{/yun}payment_list_cur{yun:}/if{/yun}" data-id="{yun:}$v{/yun}" data-integral="{yun:}$integralclass_name[$v]{/yun}" data-discount="{yun:}$integralclass_discount[$v]{/yun}">
										<div class="payment_list_text_n">
											<i class="payment_list_text_icon"></i>{yun:}$integralclass_name[$v]{/yun}
											<em class="payment_list_text_dw">{yun:}$config.integral_pricename{/yun}</em>
										</div>
									
										{yun:}if $integralclass_discount[$v]{/yun}
											<em class="payment_list_text_zk">{yun:}$integralclass_discount[$v]/10{/yun}折</em>
										{yun:}/if{/yun}
									</span>
								{yun:}/foreach{/yun}

								<div class="payment_list_zdy">
									<input type="text" id="autointegral" onBlur="comautointegral();" class="payment_list_input"placeholder="自定义" onkeyup="this.value=this.value.replace(/[^0-9]/g,'')" maxlength='6'/>{yun:}$config.integral_pricename{/yun}
								</div>
							</div>
							<div class="payment_list">
								<div class="payment_list_s" style="line-height:40px;">金额：</div>
								<div class="payment_list_r">
									<span class="payintegral" id="payintegral">0</span>元
									<input type="hidden" name="price" size="10"  id="user_vip_price">
								</div>
							</div>
							<div class="payment_list">
								<div class="payment_list_s" style="line-height:92px;">支付备注：</div>
								<div class="payment_list_r">
									<textarea name="remark" id="remark" cols="40" class="payment_list_textarea"></textarea>
								</div>
							</div>
							<div class="payment_list coupon">
								<div class="payment_list_s">&nbsp;</div>
								<div class="payment_list_r">
									<input type="submit" name="submit" class="payment_list_other" value="提交订单">
								</div>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>

<div id="remind_order" style="display:none; width:320px;">
	<div class="pay_tip_box" >
		<div class="pay_tip_top" >
			<div class="pay_tip_box_ts">温馨提示</div>
			您有 <font color="#FF3300">{yun:}$nopayorder{/yun}</font> 个订单未付款，是否继续充值！
		</div>
		<div class="">
			<a class="pay_tip_box_bth" href="index.php?c=paylog" >去付款</a>
			<a class="pay_tip_box_bth_jx" href="javascript:void(0);" onclick="layer.closeAll()">继续充值</a>
		</div>
	</div>         
</div>

<script>
	var weburl="{yun:}$config.sy_weburl{/yun}";
	'{yun:}if $smarty.get.id&&$smarty.get.type=='vip'{/yun}'
		$(document).ready(function(){
			check_rating_coupon('{yun:}$smarty.get.id{/yun}');
		});
	'{yun:}/if{/yun}'
	var integralclass=[];
	'{yun:}foreach from=$integralclass_index item=v key=k{/yun}'
		integralclass.push({
			id : '{yun:}$v{/yun}',
			integral : '{yun:}$integralclass_name[$v]{/yun}',
			discount : '{yun:}$integralclass_discount[$v]{/yun}'
		}) 
	'{yun:}/foreach{/yun}'
	function comautointegral(){
		var proportion='{yun:}$config.integral_proportion{/yun}';
		var integral=parseInt($("#autointegral").val());
		if(integral){
			var min_recharge='{yun:}$config.integral_min_recharge{/yun}';
			if(min_recharge>0&&integral<min_recharge){
				integral=min_recharge;
				$("#autointegral").val(integral);
				$("#integral").val(integral);
			}else{
				$("#autointegral").val(integral);
				$("#integral").val(integral);
			}
			var integralval=integral;
			var discountarr=[];
			for(var i in integralclass) {
				if(integralval>=parseInt(integralclass[i]['integral'])){
					discountarr.push({
					'discount':integralclass[i]['discount'],
					'id':integralclass[i]['id']
					});
				}
			}
			if(discountarr.length>0){
				var discount=discountarr[discountarr.length-1].discount;
				$("#integralid").val(discountarr[discountarr.length-1].id);
			}else{
				var discount=0;
				$("#integralid").val('');
			}
			$("#integralid").attr('data-discount',parseInt(discount));
			if(parseInt(discount)>0){
				var price=integral/proportion*parseInt(discount)/100;
			}else{
				var price=integral/proportion;
			}
			price=Math.floor(price * 100) / 100;
			$("#user_vip_price").val(price);
			$("#payintegral").html(price);
			$(".payment_list_text").removeClass('payment_list_cur');
		}
	}
	$(document).ready(function(){
		"{yun:}if $nopayorder{/yun}"
			$.layer({
				type: 1,
				title: '付款提醒',
				closeBtn: [0, true],
				border: [10, 0.3, '#000', true],
				area: ['320px', '220px'],
				page: { dom: '#remind_order' }
			});
		"{yun:}/if{/yun}"
		var proportion='{yun:}$config.integral_proportion{/yun}';
		if($.trim($("#integral").val())){
			var integral=$.trim($("#integral").val());
			var integralid=$.trim($("#integralid").val());
			
			var discount=$.trim($("#integralid").attr('data-discount'));
			if(parseInt(discount)>0){
				var price=integral/proportion*parseInt(discount)/100;
			}else{
				var price=integral/proportion;
			}
			$("#integralid").val(integralid);
			$("#integralid").attr('data-discount',parseInt(discount));
			price=Math.floor(price * 100) / 100;
			$("#user_vip_price").val(price);
			$("#payintegral").html(price);
		}
		$(".payment_list_text").click(function() {
			var val=$(this).attr('data-integral');
			var valid=$(this).attr('data-id');
			var discount=$(this).attr('data-discount');
			$(".payment_list_text").removeClass('payment_list_cur');
			$(this).addClass('payment_list_cur');
			$("#autointegral").val('');
			$("#integral").val(val);
			$("#integralid").attr('data-discount',parseInt(discount));
			$("#integralid").val(valid);
			if(parseInt(discount)>0){
				var price=val/proportion*parseInt(discount)/100;
			}else{
				var price=val/proportion;
			}
			price=Math.floor(price * 100) / 100;
			$("#user_vip_price").val(price);
			$(".payintegral").html(price);
		});
		$("#autointegral").keyup(function(e) {
			if($(this).val()){
				var integralval=$(this).val();
				var discountarr=[];
				for(var i in integralclass) {
					if(parseInt(integralval)>=parseInt(integralclass[i]['integral'])){
						discountarr.push({
						'discount':integralclass[i]['discount'],
						'id':integralclass[i]['id']
						});
					}
				}
				if(discountarr.length>0){
					var discount=discountarr[discountarr.length-1].discount;
					$("#integralid").val(discountarr[discountarr.length-1].id);
				}else{
					var discount=0;
				}
				$("#integralid").attr('data-discount',parseInt(discount));
				$(".payment_list_text").removeClass('payment_list_cur');
				$("#integral").val(integralval);
				if(parseInt(discount)>0){
					var price=integralval/proportion*parseInt(discount)/100;
				}else{
					var price=integralval/proportion;
				}
				price=Math.floor(price * 100) / 100;
				$("#user_vip_price").val(price);
				$("#payintegral").html(price);
			}else{
				$("#integral").val('0');
				$("#user_vip_price").val('0');
				$("#payintegral").html('0');
			}
		});
	});
</script> 
<input name='integral_min_recharge' value="{yun:}$config.integral_min_recharge{/yun}" type="hidden"/>
<script>
 	var second = 0;
	window.setInterval(function () {
		second ++;
	}, 1000);

	var url     = location.href, 
		refer   = document.referrer, 
		timeIn  = Math.ceil(new Date().getTime()/1000); 
	var opera   = 41; 
 	$(function(){ 
		setTimeout(function(){ 
			$.post('index.php?c=log',{url:url,refer:refer,timeIn:timeIn,second:2,opera:opera},function(data){
				if(data){
					$("#logid").val(data);
				}
			})
		},2000);
		
    }) 
	
	window.onbeforeunload = function(){ 
		var logid = $("#logid").val();
 		if(second>2){ 
			$.post('index.php?c=log&act=gxLog',{id:logid,second:second},function(data){
				if(data) {
					return false;
				}
			})
		}
   	}
</script>
{yun:}include file="$comstyle/footer.htm"{/yun}